#include <bits/stdc++.h>
using namespace std;
int n, m;
const int  N = 1e5 + 10;
int q[N], temp[N][2];

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> q[i];
	}
	for (int i = 0; i < m; ++i) {
		cin >> temp[i][0] >> temp[i][1];
	}
	for (int i = 0; i < m; ++i) {
		int sum = 0;
		for (int j = temp[i][0]; j <= temp[i][1]; ++j) {

			sum += q[j];
		}
		cout << sum << endl;
	}
	return 0;
}